import excel ".......") firstrow
describe
destring, replace
desc

tab NewsOnMedia
gen Newsmore =.
replace Newsmore =1 if NewsOnMedia >=5
replace Newsmore =0 if NewsOnMedia <5

//Descriptive Stats:
* IVs:
sum InterestCampaign NewsOnMedia DiscussPolitics Rally FinancialLast FinancialNext NationalEconomyLast NationalEconomyNext Unemployed WorryFinancialSituation LowIncome30K Conservative GOP Flag ImportantCulture SpeakEnglishImportant ReligionImportant AttendReligiousServices Bornagain Age CollegeEducated Hispanic White Parent Female HighIncome100K GrewSouth Income Ethnocentricism

* Summary Stats to Word
outreg2 using summarystats.doc, replace sum(log) keep(InterestCampaign NewsOnMedia DiscussPolitics Rally FinancialLast FinancialNext NationalEconomyLast NationalEconomyNext Unemployed WorryFinancialSituation LowIncome30K Conservative GOP Flag ImportantCulture SpeakEnglishImportant ReligionImportant AttendReligiousServices Bornagain Age CollegeEducated Hispanic White Parent Female HighIncome100K GrewSouth Income Ethnocentricism)
* Summary Stats to Excel
outreg2 using summarystats, replace sum(log) keep(InterestCampaign NewsOnMedia DiscussPolitics Rally FinancialLast FinancialNext NationalEconomyLast NationalEconomyNext Unemployed WorryFinancialSituation LowIncome30K Conservative GOP Flag ImportantCulture SpeakEnglishImportant ReligionImportant AttendReligiousServices Bornagain Age CollegeEducated Hispanic White Parent Female HighIncome100K GrewSouth Income Ethnocentricism) excel

*DVs:
** Policy toward unauthorized immigrants
tabulate Policy_unauthorized_immigrants 

* Pie Chart
graph pie [pweight = Preelectionweightfullsample], over(Policy_unauthorized_immigrants) cw plabel(_all percent, format(%4.2g)) title(Government Policy Towards Illegal Immigrants (2016) , size(medium) color(red)) legend(on stack position(5))

* Pie Chart by Republicans
graph pie [pweight = Preelectionweightfullsample], over(Policy_unauthorized_immigrants) cw plabel(_all percent, format(%4.2g)) by(, title(Government Policy Towards Illegal Immigrants by Republicans 2016, size(medium) color(red))) by(, legend(on position(5))) legend(stack) by(GOP, total)


** Policy toward Dreamers
tab Children_Brought_Illegally1
recode Children_Brought_Illegally1 (1=0) (0=1)
tab Children_Brought_Illegally1


* Pie Chart
graph pie [pweight = Preelectionweightfullsample], over(Children_Brought_Illegally1) cw plabel(_all percent, format(%4.2g)) title(Opinion on Proposal to Allow Citizenship to Dreamers (2016), size(medium) color(red)) legend(on stack position(5))

* Pie Chart by Republicans

graph pie [pweight = Preelectionweightfullsample], over(Children_Brought_Illegally1) cw plabel(_all percent, format(%4.2g)) by(, title(Opinion on Proposal to Allow Citizenship to Dreamers by Republicans 2016, size(medium) color(red))) by(, legend(on position(5))) legend(stack) by(GOP, total)


** Feeling Thermo Illegal Immigrants
sum FTIllegalImmigrants
by GOP, sort : summarize FTIllegalImmigrants

histogram FTIllegalImmigrants, percent normal ytitle(Percentage) xtitle(Feeling Thermometer) title(Histogram of Feeling Thermometer Illegal Immigrants 2016, size(medium) color(red))


// Normalization all the independent variables to 0‐1
sum InterestCampaign NewsOnMedia DiscussPolitics Rally FinancialLast FinancialNext NationalEconomyLast NationalEconomyNext Unemployed WorryFinancialSituation LowIncome30K Conservative GOP Flag ImportantCulture SpeakEnglishImportant ReligionImportant AttendReligiousServices Bornagain Age CollegeEducated Hispanic White Parent Female HighIncome100K GrewSouth Income Ethnocentricism

recode InterestCampaign (1=0) (2=.5) (3=1)
replace NewsOnMedia= NewsOnMedia/7 
replace DiscussPolitics = DiscussPolitics/7

recode FinancialLast (5=1) (4=.75) (3=.5) (2=.25) (1=0)
recode FinancialNext (5=1) (4=.75) (3=.5) (2=.25) (1=0)
recode NationalEconomyLast (5=1) (4=.75) (3=.5) (2=.25) (1=0)
recode NationalEconomyNext (5=1) (4=.75) (3=.5) (2=.25) (1=0)
recode WorryFinancialSituation (5=1) (4=.75) (3=.5) (2=.25) (1=0)

replace Flag = (Flag - 1) / 6
replace ImportantCulture = (ImportantCulture - 1) / 3
replace SpeakEnglishImportant =  (SpeakEnglishImportant - 1) / 3

recode AttendReligiousServices (5=1) (4=.75) (3=.5) (2=.25) (1=0)

replace Ethnocentricism = (Ethnocentricism +100) / 200

replace Income = (Income-1)/27
replace Age = (Age - 18)/73

sum InterestCampaign NewsOnMedia DiscussPolitics Rally FinancialLast FinancialNext NationalEconomyLast NationalEconomyNext Unemployed WorryFinancialSituation LowIncome30K Conservative GOP Flag ImportantCulture SpeakEnglishImportant ReligionImportant AttendReligiousServices Bornagain Age CollegeEducated Hispanic White Parent Female HighIncome100K GrewSouth Income Ethnocentricism


//Regression 
*Pre-Election
*DV: Government Policy Toward Illegal Immigrants
svyset [pweight= Preelectionweightfullsample ], strata( Stratumfullsample ) psu( VariancePSUFullsample)

ologit Policy_unauthorized_immigrants FinancialLast FinancialNext NationalEconomyLast NationalEconomyNext Unemployed WorryFinancialSituation LowIncome30K Flag ImportantCulture SpeakEnglishImportant Ethnocentricism GOP Conservative ReligionImportant AttendReligiousServices Bornagain InterestCampaign NewsOnMedia DiscussPolitics Rally Age CollegeEducated Hispanic White Parent Female HighIncome100K GrewSouth Income 

outreg2 using regression_results, replace excel dec(2)

*DV: Dreamers Sent back or Stay
svyset [pweight= Preelectionweightfullsample ], strata( Stratumfullsample ) psu( VariancePSUFullsample)
svy: logit Children_Brought_Illegally1 FinancialLast FinancialNext NationalEconomyLast NationalEconomyNext Unemployed WorryFinancialSituation LowIncome30K Flag ImportantCulture SpeakEnglishImportant Ethnocentricism GOP Conservative ReligionImportant AttendReligiousServices Bornagain InterestCampaign NewsOnMedia DiscussPolitics Rally Age CollegeEducated Hispanic White Parent Female HighIncome100K GrewSouth Income 

outreg2 using regression_results, append excel dec(2)

*Post Election
*DV: Feeling Thermo Illegal Immigrants
svyset [pweight= Postelectionweightfullsampl ], strata( Stratumfullsample ) psu( VariancePSUFullsample)
svy: reg FTIllegalImmigrants FinancialLast FinancialNext NationalEconomyLast NationalEconomyNext Unemployed WorryFinancialSituation LowIncome30K Flag ImportantCulture SpeakEnglishImportant Ethnocentricism GOP Conservative ReligionImportant AttendReligiousServices Bornagain InterestCampaign NewsOnMedia DiscussPolitics Rally Age CollegeEducated Hispanic White Parent Female HighIncome100K GrewSouth Income 

outreg2 using regression_results, append excel dec(2)

***INTERACTION

** DV: Policy toward unauthorized immigrants: Interaction terms
*Rally##GOP

svyset [pweight= Preelectionweightfullsample ], strata( Stratumfullsample ) psu( VariancePSUFullsample)

ologit Policy_unauthorized_immigrants FinancialLast FinancialNext NationalEconomyLast NationalEconomyNext Unemployed WorryFinancialSituation LowIncome30K Flag ImportantCulture SpeakEnglishImportant Ethnocentricism Conservative ReligionImportant AttendReligiousServices Bornagain InterestCampaign NewsOnMedia DiscussPolitics Rally##GOP Age CollegeEducated Hispanic White Parent Female HighIncome100K GrewSouth Income, level (84) 

margins Rally , at(GOP=(0 1)) level (84)
marginsplot
margins Rally , at(GOP=1) level (84)
marginsplot

*InterestCampaign##GOP
recode InterestCampaign (0=1) (.5=2) (1=3)
svy: ologit Policy_unauthorized_immigrants FinancialLast FinancialNext NationalEconomyLast NationalEconomyNext Unemployed WorryFinancialSituation LowIncome30K Flag ImportantCulture SpeakEnglishImportant Ethnocentricism Conservative ReligionImportant AttendReligiousServices Bornagain InterestCampaign##GOP NewsOnMedia DiscussPolitics Rally Age CollegeEducated Hispanic White Parent Female HighIncome100K GrewSouth Income , level (84) 

margins InterestCampaign , at(GOP=(0 1)) level (84)
marginsplot
margins InterestCampaign , at(GOP=1) level (84)
marginsplot

*Newsmore##GOP

svy: ologit Policy_unauthorized_immigrants FinancialLast FinancialNext NationalEconomyLast NationalEconomyNext Unemployed WorryFinancialSituation LowIncome30K Flag ImportantCulture SpeakEnglishImportant Ethnocentricism Conservative ReligionImportant AttendReligiousServices Bornagain InterestCampaign Newsmore##GOP DiscussPolitics Rally Age CollegeEducated Hispanic White Parent Female HighIncome100K GrewSouth Income , level (84) 

margins Newsmore , at(GOP=(0 1)) level (84)
marginsplot
margins Newsmore , at(GOP=1) level (84)
marginsplot


** DV: citizenship to dreamers: Interaction terms

*Rally##GOP
svy: logit Children_Brought_Illegally1 FinancialLast FinancialNext NationalEconomyLast NationalEconomyNext Unemployed WorryFinancialSituation LowIncome30K Flag ImportantCulture SpeakEnglishImportant Ethnocentricism Conservative ReligionImportant AttendReligiousServices Bornagain InterestCampaign NewsOnMedia DiscussPolitics Rally##GOP Age CollegeEducated Hispanic White Parent Female HighIncome100K GrewSouth Income, level (84)  

margins Rally , at(GOP=(0 1)) level (84)
marginsplot
margins Rally , at(GOP=1) level (84)
marginsplot

*InterestCampaign##GOP
svy: logit Children_Brought_Illegally1 FinancialLast FinancialNext NationalEconomyLast NationalEconomyNext Unemployed WorryFinancialSituation LowIncome30K Flag ImportantCulture SpeakEnglishImportant Ethnocentricism Conservative ReligionImportant AttendReligiousServices Bornagain InterestCampaign##GOP NewsOnMedia DiscussPolitics Rally Age CollegeEducated Hispanic White Parent Female HighIncome100K GrewSouth Income , level (84) 

margins InterestCampaign , at(GOP=(0 1)) level (84)
marginsplot
margins InterestCampaign , at(GOP=1) level (84)
marginsplot

*Newsmore##GOP
svy: logit Children_Brought_Illegally1 FinancialLast FinancialNext NationalEconomyLast NationalEconomyNext Unemployed WorryFinancialSituation LowIncome30K Flag ImportantCulture SpeakEnglishImportant Ethnocentricism Conservative ReligionImportant AttendReligiousServices Bornagain InterestCampaign Newsmore##GOP DiscussPolitics Rally Age CollegeEducated Hispanic White Parent Female HighIncome100K GrewSouth Income , level (84) 

margins Newsmore , at(GOP=(0 1)) level (84)
marginsplot
margins Newsmore , at(GOP=1) level (84)
marginsplot

** DV: Feeling Thermo Illegal immigrants: Interaction terms
*Rally##GOP
svyset [pweight= Postelectionweightfullsampl ], strata( Stratumfullsample ) psu( VariancePSUFullsample)
svy: reg FTIllegalImmigrants FinancialLast FinancialNext NationalEconomyLast NationalEconomyNext Unemployed WorryFinancialSituation LowIncome30K Flag ImportantCulture SpeakEnglishImportant Ethnocentricism Conservative ReligionImportant AttendReligiousServices Bornagain InterestCampaign NewsOnMedia DiscussPolitics Rally##GOP Age CollegeEducated Hispanic White Parent Female HighIncome100K GrewSouth Income , level (84) 

margins Rally , at(GOP=(0 1)) level (84)
marginsplot
margins Rally , at(GOP=1) level (84)
marginsplot
 
*InterestCampaign##GOP

svy: reg FTIllegalImmigrants FinancialLast FinancialNext NationalEconomyLast NationalEconomyNext Unemployed WorryFinancialSituation LowIncome30K Flag ImportantCulture SpeakEnglishImportant Ethnocentricism Conservative ReligionImportant AttendReligiousServices Bornagain InterestCampaign##GOP NewsOnMedia DiscussPolitics Rally Age CollegeEducated Hispanic White Parent Female HighIncome100K GrewSouth Income , level (84) 

margins InterestCampaign , at(GOP=(0 1)) level (84)
marginsplot
margins InterestCampaign , at(GOP=1) level (84)
marginsplot 
 
*Newsmore##GOP
svy: reg FTIllegalImmigrants FinancialLast FinancialNext NationalEconomyLast NationalEconomyNext Unemployed WorryFinancialSituation LowIncome30K Flag ImportantCulture SpeakEnglishImportant Ethnocentricism Conservative ReligionImportant AttendReligiousServices Bornagain InterestCampaign Newsmore##GOP DiscussPolitics Rally Age CollegeEducated Hispanic White Parent Female HighIncome100K GrewSouth Income , level (84) 

margins Newsmore , at(GOP=(0 1)) level (84)
marginsplot
margins Newsmore , at(GOP=1) level (84)
marginsplot


***VOTE CHOICE / Feeling Thermo Trump
tab Vote_2016
encode Vote_2016, gen (vote_choice_2016)

svyset [pweight= Postelectionweightfullsampl ], strata( Stratumfullsample ) psu( VariancePSUFullsample)
*Multinominal Logistic Regression with Immigration Variables
svy: mlogit vote_choice_2016 Policy_unauthorized_immigrants Children_Brought_Illegally1 ImmigrationLevels ImmigrationTakesAwayJobs FTIllegalImmigrants, baseoutcome (3)

outreg2 using vote_choice_2016_results, replace excel dec(2)

margins, at (FTIllegalImmigrants= (0(10)100)) predict (outcome (3)) vsquish level (84)
marginsplot

margins, at ( Policy_unauthorized_immigrants= (1(1)4)) predict (outcome (3)) vsquish level (84)
marginsplot

margins, at ( ImmigrationLevels= (1(1)5)) predict (outcome (3)) vsquish level (84)
marginsplot

margins, at ( ImmigrationTakesAwayJobs= (1(1)4)) predict (outcome (3)) vsquish level (84)
marginsplot


// Normalization Immigration variables to 0‐1
sum Policy_unauthorized_immigrants Children_Brought_Illegally1 ImmigrationLevels ImmigrationTakesAwayJobs FTIllegalImmigrants


replace Policy_unauthorized_immigrants = (Policy_unauthorized_immigrants - 1)/3
replace ImmigrationLevels  = (ImmigrationLevels  - 1)/4
replace ImmigrationTakesAwayJobs  = (ImmigrationTakesAwayJobs  - 1)/3
replace FTIllegalImmigrants  = FTIllegalImmigrants/100

sum Policy_unauthorized_immigrants Children_Brought_Illegally1 ImmigrationLevels ImmigrationTakesAwayJobs FTIllegalImmigrants


*Multinominal Logistic Regression with Other Variables

svy: mlogit vote_choice_2016 Policy_unauthorized_immigrants Children_Brought_Illegally1 ImmigrationLevels ImmigrationTakesAwayJobs FTIllegalImmigrants, baseoutcome (3)

outreg2 using vote_choice_2016_results, replace excel dec(2)


svy: mlogit vote_choice_2016 Policy_unauthorized_immigrants Children_Brought_Illegally1 ImmigrationLevels ImmigrationTakesAwayJobs FTIllegalImmigrants FinancialLast FinancialNext NationalEconomyLast NationalEconomyNext Unemployed WorryFinancialSituation LowIncome30K Flag ImportantCulture SpeakEnglishImportant Ethnocentricism Conservative GOP ReligionImportant AttendReligiousServices Bornagain InterestCampaign Newsmore DiscussPolitics Rally Age CollegeEducated Hispanic White Parent Female HighIncome100K GrewSouth Income  , baseoutcome (3)

outreg2 using vote_choice_2016_results, append excel dec(2)


*Regression with Feeling Thermo Trump
svy: reg  FT_Trump_post  Policy_unauthorized_immigrants Children_Brought_Illegally1 ImmigrationLevels ImmigrationTakesAwayJobs FTIllegalImmigrants

coefplot, drop(_cons) xline(0) title("Coefficient Plot for Feeling Thermo Trump", size(small))

outreg2 using vote_choice_2016_results, append excel dec(2)


svy: reg  FT_Trump_post Policy_unauthorized_immigrants Children_Brought_Illegally1 ImmigrationLevels ImmigrationTakesAwayJobs FTIllegalImmigrants FinancialLast  NationalEconomyLast Unemployed WorryFinancialSituation LowIncome30K  ImportantCulture SpeakEnglishImportant Ethnocentricism Conservative GOP  AttendReligiousServices Bornagain InterestCampaign Rally Age CollegeEducated Hispanic White Parent Female HighIncome100K GrewSouth 

coefplot, drop(_cons) xline(0) title("Coefficient Plot for Feeling Thermo Trump", size(small) color(red))

outreg2 using vote_choice_2016_results, append excel dec(2)


* 2016 Vote choice model:
 
svy: logit vote4Trump Policy_unauthorized_immigrants Children_Brought_Illegally1 ImmigrationLevels ImmigrationTakesAwayJobs FTIllegalImmigrants FinancialLast FinancialNext NationalEconomyLast NationalEconomyNext Unemployed WorryFinancialSituation LowIncome30K Flag ImportantCulture SpeakEnglishImportant Ethnocentricism Conservative GOP ReligionImportant AttendReligiousServices Bornagain InterestCampaign Newsmore DiscussPolitics Rally Age CollegeEducated Hispanic White Parent Female GrewSouth HighIncome100K
 
estimates store main_treat
 
coefplot main_treat, xline (0) level(95)



